package com.hst.web.base.proxy;

import java.sql.Timestamp;
import java.util.*;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.hst.core.Page;
import com.hst.core.ServiceContext;
import com.hst.core.dao.IORDao;
import com.hst.core.dao.ISQLDao;
import com.hst.core.dao.ORQuery;
import com.hst.core.dao.ORQuery.Op;
import com.hst.core.meta.MetaData;
import com.hst.core.meta.MetaRepository;
import com.hst.core.meta.proxies.DefaultDataProxy;
import com.hst.web.auth.po.User;
import com.hst.web.base.entity.TAccountIdentity;
import com.hst.web.base.entity.TCompanyDept;
import com.hst.web.base.entity.TCompanyEmployee;
import com.hst.web.base.entity.TCompanyInfo;
import com.hst.web.base.entity.TContractorInfo;
import com.hst.web.base.entity.TDeptEmployee;
import com.hst.web.base.entity.TEmployeeContractorDept;
import com.hst.web.base.entity.TEmployeeOperate;
import com.hst.web.base.service.UserRoleService;
import com.hst.web.base.ui.CompanyEmployee;
import com.hst.web.base.ui.EmployeeIdentify;
import com.hst.web.common.utils.ConstantUtil;
import com.hst.web.common.utils.DateTimeUtil;
import com.hst.web.common.utils.PapersNumberUtils;
import com.hst.web.sys.entity.TRole;
import com.hst.web.sys.entity.TUser;
import com.hst.web.sys.entity.TUserRole;

public class CompanyEmployeeYckProxy extends DefaultDataProxy {

    /**
     * 发证状态：未发证
     */
    private static final String PUSHFLAG_NOT = "0";

    /**
     * 人员操作状态：离职
     */
    private static final String OPTYPE_DEPART = "2";

    @Autowired
    IORDao dao;

    @Autowired
    ISQLDao sql;

    @Autowired
    MetaRepository mr;

    @SuppressWarnings("unchecked")
    @Override
    public Page<?> list(Map<String, ?> query, int pageIdx) {
        UserRoleService.addCompanyEmpParam((Map<String, Object>) query);
        String yearCheckStatus = (String) query.get("yearCheckStatus");
        
		String currMonth = DateTimeUtil.getCurrMonth();
		Date baseYearLastDate = DateTimeUtil.getCurrYearLast();
		if ("11".equals(currMonth) || "12".equals(currMonth)) {
			baseYearLastDate = DateTimeUtil.getNextYearLast();
		} else if ("1".equals(currMonth) || "2".equals(currMonth) || "3".equals(currMonth)) {
			baseYearLastDate = DateTimeUtil.getCurrYearLast();
		} else {
			baseYearLastDate = DateTimeUtil.getCurrYearLast();
		}
		Map<String,Object> queryMap = (Map<String, Object>) query;
		queryMap.put("endExpirydate", DateTimeUtil.dateToString(baseYearLastDate, "yyyy-MM-dd"));
        return sql.list("employee.list-company-employee-yck", queryMap, pageIdx, Page.getPageSize());
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<?> list(Map<String, ?> query) {
        UserRoleService.addCompanyEmpParam((Map<String, Object>) query);
        return sql.query("employee.list-company-employee-yck", query);
    }

}
